 <{extends file="<{$tempdir}>/public/wxsite.html"}>  
<{block name=extendcss}> 
<link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/css/public.css">   
 <link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/css/shoplist.css">   
 <style>
     #supplierlist {
         width: 100%;
         background-color: #fff;
     }
     #supplierlist li {
         padding: 10px 1.7777%;
         border-bottom: 1px solid #e6e6e6;
         display: -webkit-box;
         display: -moz-box;
     }

     #supplierlist li .homscrbusinimg {
         width: 100px;
         height: 85px;
         overflow: hidden;
         float:left;
     }

     #supplierlist li .homscrbusinR {
         padding-left: 5px;
         /*float:left;*/
     }

     #supplierlist li .homscrbusinR div{
         line-height:21px;
     }
     #supplierlist li .homscrbusinR .homscrbusint {
         width: 100%;
         overflow: hidden;
     }

     #supplierlist li .homscrbusinR .homscrbusint h3{
         font-size: 16px;
         color: #333333;
         float: left;
         font-weight: normal;
     }

     #supplierlist li .homscrbusinR .homscrbusint i{
         width: 57px;
         height: 15px;
         background-image: url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/lab_wzps.png);
         background-size: 100%;
         margin: 4px 0 0 8px;
         float: left;
     }

     #supplierlist li .homscrbusinR .homscrbusinsale {
         font-size: 1.2rem;
     }

     #supplierlist li .homscrbusinR .homscrbusinsale i {
         color: #fac82f;
         margin-right: 2px;
     }

     #supplierlist li .homscrbusinR .homscrbusinsale span {
         color: #666666;
         margin-left: 4px;
     }

     #supplierlist li .homscrbusinR .homscrbusinpric {
         color: #666666;
         font-size: 12px;
     }

     #supplierlist li .homscrbusinR .homscrbusinpric span{
         color: #ff6e6e;
         font-size: 12px;
     }

     #supplierlist li .homscrbusinR .homscrbusinadd {
         color: #a3a3a3;
         font-size: 12px;
     }
     .container{
         padding-bottom: 60px;
     }
     #search_input{
         width:80%;
         float:left;
         background:#EFEFEF;
         height:42px;
         line-height:42px;
         border-radius:5px;
         margin: 0px;
         padding: 0px 0px;
         border: 0px;
         margin-top:5px;
         padding-left:4px;
     }
 </style>
<{/block}>
 <{block name=extendjs}> 
 <script src="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/js/template.min.js"></script>     
 <script>
var can_show = true;
var page = 1;
var catid = <{$typeid|default:0}>;
var order = 0;
var qsjid = 0;
var typeid = <{$typeid|default:0}>;
var myaddress = '<{$myaddress}>';
var search_input = '<{$search_input}>';
var shopshowtype  = '<{$shopshowtype}>';
$(function(){ 
shopdata();

	if( typeid != '' ){
		$('.kwselected').html( $(".typeid_"+typeid).attr('catename') );
		
  
			 $(".typeid_"+typeid).addClass('xz').siblings().removeClass('xz');
		   $('#toolbar').find('.se').removeClass('se');
		   $('#toolbar').find('.sh').removeClass('sh');
		   $('#supplierlist').html('');
		
		   $('#toolbar').find('li').eq(0).html('<a>'+ $(".typeid_"+typeid).text()+'<b class=""></b></a>');
		   catid = $(".typeid_"+typeid).attr('id');//alert(this).
		   can_show = true; 
		   page = 1;
		   
		   $(".kouweidiv").hide();
		   
		 
	}
	

	 
 		$('#toolbar .sele>li').bind("click", function() {   
	    $('#toolbar .sele>b').removeClass('se');
     $(this).addClass('se').siblings().removeClass('se');
     $(this).find('b').addClass('se');
      $('#toolbar .sub').addClass('sh');
       var cc = $('#toolbar .sele').find('li').index(this); 
       $('#toolbar .lizd').eq(cc).show().siblings().hide();//('sh'); 
   
      });
 });
function shopdata(){ 
	   $('#loading').show();
 	   $(".mBxCr").show(); 
 	   var url = siteurl+'/index.php?ctrl=wxsite&action=shophuilistdata&areaid=<{$areaid}>&datatype=json&random=@random@';  
 	    $.ajax({ 
      dataType: "json", 
      data:{page:page,search_input:search_input,order:order,catid:catid,qsjid:qsjid}, 
       url: url.replace('@random@', 1+Math.round(Math.random()*1000)),  
       success: function(content) {    
       	 if(content.error == false) 
      	{ 

      		  if(content.msg.length > 0){

      		  		var cc = $('.clkitm').length;

      		     $.each(content.msg, function(i,val){     
 		             //   var htmls = template.render('shoplist', {list:val}); 
 		                var htmls = trancertdata(val);
                   $('#supplierlist').append(htmls); 
                   $('.clkitm').eq(Number(i)+Number(cc)).fadeIn(); 
               });  
               page = Number(page+1);  
               $(".mBxCr").hide(); 
               $('#loading').hide();
      		  }else{ 
      		      can_show ==  false; 
      		      if(page == 1){ 
      		      	 error($('#supplierlist'),'未查找到满足条件的数据'); 
      		      	 $(".mBxCr").hide(); 
      		      }else{ 
//      		        $('#loadtip').text('数据加载完毕');
                      $('#loadtip').hide();
      		      }
      		      $('#loading').hide();

      		  }

      	}else{ 
      			 can_show ==  false; 
    	       error($('#supplierlist'),content.msg); 
    	       $('#loading').hide();
      	}  
      	 
	     }, 
       error: function(content) {  
        	can_show ==  false; 
    	    error($('#supplierlist'),'店铺数据为空'); 
    	    $('#loading').hide();
	     }

     });   

}
function trancertdata(datas){
    var backdata = '';
    if(datas.shopshui != ''){
    backdata +='<li> ';
    backdata += '<a href="'+siteurl+'/index.php?ctrl=wxsite&action=shophuishow&id='+datas.id+'">';
    backdata +='<div class="homscrbusinimg"><img src="'+datas.shoplogo+'"></div>';
    backdata +='<div class="homscrbusinR">';
    backdata +='<div class="homscrbusint"><h3>'+datas.shopname+'</h3>';
    if(datas.sendtype == 0){
        backdata +='<i></i>';
    }
    backdata +='</div>';
    backdata +='<div class="homscrbusinsale">';
    for(var i=0;i<datas.point;i++){
        backdata +='<i class="fa fa-star"></i>';
    }
    for(var i=0;i<5-datas.point;i++){
        backdata +='<i class="fa fa-star" style="color:#f1f1f1;"></i>';
    }
    backdata +='<span>月售'+datas.ordercount+'单</span>';
    backdata +='</div>';
    if(datas.shopshui != ''){
        backdata +='<div class="homscrbusinpric"><span>'+datas.shopshui.name+'</span></div>';
    }
    backdata +='<div class="homscrbusinadd">距离'+datas.juli+'&nbsp;&nbsp;'+datas.address+'</div>';
    backdata +='</div>';
    backdata +='</a> ';
    backdata +='</li>';
    }
    return backdata;
}
$(window).scroll(function(){   //滚动获取数据 
	if(can_show == true && $(".mBxCr").is(":hidden") == true){ 
    if ($(document).height() - $(this).scrollTop() - $(this).height()<50) shopdata();   
  } 
});

</script>
<script>
	var startX = 0, startY = 0;
 
	function touchSatrtFunc(evt) {
                try
                {
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等

                    var touch = evt.touches[0]; //获取第一个触点
                    var x = Number(touch.pageX); //页面触点X坐标
                    var y = Number(touch.pageY); //页面触点Y坐标
                    //记录触点初始位置
                    startX = x;
                    startY = y; 
                 //  var text = 'TouchStart事件触发：（' + x + ', ' + y + '）';
                 //  document.getElementById("result").innerHTML = text;
                }
                catch (e) {
                   // alert('touchSatrtFunc：' + e.message);
                }
  }
	function touchMoveFunc(evt,targetname) {
    try{
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等
                    var touch = evt.touches[0]; //获取第一个触点
                    var x = Number(touch.pageX); //页面触点X坐标
                    var y = Number(touch.pageY); //页面触点Y坐标
                    //alert($(evt).html());

                  //  var text = 'TouchMove事件触发：（' + x + ', ' + y + '）';

                    //判断滑动方向
                    if (x - startX != 0) {
                        // text += '<br/>左右滑动';
                        // -的时候为向左滑动  +  向右滑动
                        var mudi = x - startX;
                     //   text += '<br/>'+mudi;
                        var oldpostion = parseInt($('#'+targetname).css('left'));
                        var nowposition = Number(oldpostion) + Number(mudi);
                        var zongchang = parseInt($('#'+targetname).css('width'));
                     //   text += '<br/>新位置'+nowposition;
                        if(nowposition > 0){
                        	$('#'+targetname).css({left:0});  
                        }else{ 
                        	var checkchang = Number(zongchang)+Number(nowposition);
                        	if(checkchang > 0){
                          $('#'+targetname).css({left:nowposition});  
                          }else{
                          	 var dochang = 200 - Number(zongchang);
                            $('#'+targetname).css({left:dochang});   
                          }
                        }
                      
                    }
                    if (y - startY != 0) {
                      //  text += '<br/>上下滑动';
                    }

                  //  document.getElementById("result").innerHTML = text;
     }catch (e) {
                  //  alert('touchMoveFunc：' + e.message);
    }
  }
  function touchEndFunc(evt) {
                try {
                    //evt.preventDefault(); //阻止触摸时浏览器的缩放、滚动条滚动等

                 //   var text = 'TouchEnd事件触发';
                //    document.getElementById("result").innerHTML = text;
                }
                catch (e) {
                  //  alert('touchEndFunc：' + e.message);
                }
  }

	function bindEvent() {
         document.getElementById('cuisien').addEventListener('touchstart', touchSatrtFunc, false); 
         document.getElementById('cuisien').addEventListener('touchmove', function(e) { touchMoveFunc(e,'cuisien'); } , false);
         document.addEventListener('touchend', touchEndFunc, false); 
  } 
	function isTouchDevice() { 
      try {
         document.createEvent("TouchEvent"); 
         bindEvent(); //绑定事件
      }
      catch (e) { 
      }
  } 
  window.onload = isTouchDevice;
 </script>
<{/block}>
<{block name=myScrolljs}>
<script>
    var myScroll, pullDownEl, pullDownOffset,pulldowncate,
	pullUpEl, pullUpOffset,
	generatedCount = 0;
function pullUpAction () {
	setTimeout(function () {	// <-- Simulate network congestion, remove setTimeout from production!
		if(can_show == true && $(".mBxCr").is(":hidden") == true){  
        shopdata();   
    } 
		myScroll.refresh();		// Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
}

function loaded() {
	pullDownEl = document.getElementById('pullDown');
	pullDownOffset = pullDownEl.offsetHeight;
	pullUpEl = document.getElementById('pullUp');	
	pullUpOffset = pullUpEl.offsetHeight;
	
	myScroll = new iScroll('wrapper', {
		hScrollbar:false, 
		vScrollbar:false,
		useTransition: true,
		topOffset: pullDownOffset,
		onRefresh: function () {
			if (pullDownEl.className.match('loading')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
			} else if (pullUpEl.className.match('loading')) {
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
			}
		},
		onScrollMove: function () {
			if (this.y > 5 && !pullDownEl.className.match('flip')) {
				pullDownEl.className = 'flip';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
				this.minScrollY = 0;
			} else if (this.y < 5 && pullDownEl.className.match('flip')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
				this.minScrollY = -pullDownOffset;
			} else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
				pullUpEl.className = 'flip';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Release to refresh...';
				this.maxScrollY = this.maxScrollY;
			} else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';
				this.maxScrollY = pullUpOffset;
			}
		},
		onScrollEnd: function () {
			if (pullDownEl.className.match('flip')) {
				pullDownEl.className = 'loading';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';				
				pullDownAction();	// Execute custom function (ajax call?)
			} else if (pullUpEl.className.match('flip')) {
				pullUpEl.className = 'loading';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...';				
				pullUpAction();	// Execute custom function (ajax call?)
			}
		}
	});
	pulldowncate = new iScroll('wrappercate', {
		hScrollbar:false, 
		vScrollbar:false,
		useTransition: true,
		topOffset: pullDownOffset
		
	});
	
	setTimeout(function () { document.getElementById('wrappercate').style.left = '0'; }, 800);
	setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);


</script>

<{/block}>
<{block name=sitetitle}><{$sitename}><{/block}>
<{block name=hearnav}>
<div class="toptitCon">
 <div class="toptitBox">
     <div class="toptitL"><i></i></div>
     <div class="toptitC"><h3 style="font-size:16px;">闪惠商家</h3></div>
 </div>
</div>
<{/block}>
<{block name=blockcontent}> 
<style>
#cuisien{padding:0px;}
#cuisien li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;}
.kouweixz{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kouweixzpx{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kouweixzqsj{ width:33.3%; float:left;background:#fff; font-size:14px;  height:41px; line-height:41px; border-bottom:1px solid #d9d9d9; text-align:center; color:#0088cc; border-right:1px solid #e5e5e5;}
.kwselected{width:90%; margin:0 auto;}
.kwselectedpx{width:90%; margin:0 auto;}
.kwselectedqsj{width:90%; margin:0 auto;}
.kouweiwx{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiwxpx{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiwxqsj{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiBg11.png) #ffffff right center no-repeat; color:#323232; font-size:14px; font-weight:normal;}
.kouweiokERR{background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/kouweiseBg.png) #ffffff right center no-repeat;}
.kouweidiv{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:0px; border:1px solid #d9d9d9; }
.kouweidivpx{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:33.3%; border-bottom:1px solid #d9d9d9; }
#cuisienpx{padding:0px;}
#cuisienpx li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;border: 1px solid #e5e5e5; background:#fff;font-size: 1.5rem;}
.kouweidivqsj{ display:none;width:33.3%;background:#ffffff; position:absolute;z-index:999; top:85px; left:66.6%; border-bottom:1px solid #d9d9d9; }
#cuisienqsj{padding:0px;}
#cuisienqsj li{ text-align:center;width:100%;clear:both;display: block; height:40px; line-height:40px; padding:0px; margin:0px;border: 1px solid #e5e5e5; background:#fff;font-size: 1.5rem;}
#cuisienpx li.xz {
  background-color: #fe5052;
  color: #fff;
}
#cuisienpx li.xz a {
  color: #fff;
}
#cuisienqsj li.xz {
  background-color: #fe5052;
  color: #fff;
}
#cuisienqsj li.xz a {
  color: #fff;
}
</style>
 <div class="caipinglist float_top" id="ucsss" style="position:fixed;z-index:1000; height:52px;">  
    <form id="fabupaotui" method="post" action="<{ofunc type=url link="/wxsite/shophui"}>">
  <div class="header-bar" style="height:52px; background:none; border-bottom:1px solid #CACACA;">
		
		<div style="width:95%; margin:0 auto;">
			<input type="text" value="<{$search_input}>" id="search_input" name="search_input" placeholder="输入闪惠商家名称"/>
	<input type="submit" value="搜索" id="searchbutton" style="width:18%;color:#fff; background:#fe5052;border-radius:5px;float:right; height:42px;  padding: 0px;
    border: 0px;line-height:42px;margin-top:5px; " />
		</div>
		
        </div>
</form>
    </div>

 <div id="wrapper" style="margin-top:52px;bottom:0px;">
	<div id="scroller">
		
		<div id="pullDown" style="display:none;">
			<span class="pullDownIcon"></span><span class="pullDownLabel">Pull down to refresh...</span>
		</div>

  <div id="result"></div>

  <div class="container" id="relist">

  	<section>

  		<ul id="supplierlist">

  			 

     </ul>

     <!--<div class="mBxCr" style="display: none;"><span class="more" id="loadtip">加载更多</span></div>-->

    </section>
  </div>
   
   <div id="pullUp" style="display:none;">
			<span class="pullUpIcon"></span><span class="pullUpLabel">Pull up to refresh...</span>
		</div>
   
   
   
</div>
</div>
<{/block}>